<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div ui-layout-center">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="song-form">

				<input type="hidden" id="subjectId" name="subjectId">
				<div class="select-list">
					<ul>
						<li>
							类别：<select name="type" th:with="type=${@dict.getType('zl_song_leibie')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						</li>
						<li>
							等级：<select name="level" th:with="type=${@dict.getType('zl_subject_level')}">
							<option value="">所有</option>
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:data-remark="${dict.remark}" th:value="${dict.dictValue}"></option>
						</select>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="container-div">
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="project:subject:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="project:subject:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="project:subject:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>

	</div>
</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('project:subject:edit')}]];
        var removeFlag = [[${@permission.hasPermi('project:subject:remove')}]];
        var datas = [[${@dict.getType('zl_song_leibie')}]];
        var data;
        var prefix = ctx + "project/subject";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "教学等级",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'subjectId', 
					title : '编号' 
				},
				{
					field : 'type', 
					title : '类别' ,
                    formatter: function(value, row, index) {
					    if("level"==value){
                            data = [[${@dict.getType('zl_subject_level')}]];
						} else {
                            data = [[${@dict.getType('zl_subject_year')}]];
                    }
                        return $.table.selectDictLabel(datas, value);
                    }
				},
				{
					field : 'miaoshu',
					title : '描述' 
				},
				{
					field : 'level', 
					title : '级别' ,
                    formatter: function(value, row, index) {
					    console.log(data)
						console.log(value)
                        return $.table.selectDictLabel(data,value);
                    }
				},
				{
					field : 'price', 
					title : '价格' 
				},
				{
					field : 'remark', 
					title : '备注' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.subjectId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.subjectId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>